/*
    This file is part of p4f
    Copyright (C) 2009  Sebastian Fernandez

    p4f is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as 
    published by the Free Software Foundation, either version 3 of the 
    License, or (at your option) any later version.

    p4f is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
*/

#ifndef _HTTP_H_
#define _HTTP_H_

#include <socket.h>
#include <string>

struct _http_header{
	std::string user-agent;
	std::string content-encoding;
	std::string cookie;
	std::string referer;
	std::string host;
	std::string content-type;
	std::string server;
	std::string connection;
	std::string content-length;
};

struct _http_resources{
	std::string name;
	std::string type;
	char *data;
	int length;
};

class HTTPServer: public Thread{
public:
	HTTPServer();
	~HTTPServer();

	int add_resource(std::string res, std::string type, std::string data);
	int add_resource(char *res, char *type, char *data, int length);
	virtual void do_GET();

	//This will start the main server thread
	bool serve(int port);
	void run (void *);

protected:
	TcpSocket s;
	struct _http_header http_header;
	struct _http_resources *http_resources;
};

class HTTPClient{
public:
	HTTPClient();
	~HTTPClient();

};

#endif /* _HTTP_H_ */
